data   segment
        n       dw  6
        result  dw  ?   		; 存放FIB(n)的结果
data   ends

codes segment
    assume ds:data,cs:codes
start:
    mov ax,data
    mov ds,ax
    mov cx,n
	cmp cx,1
	je fib1
	cmp cx,2
	je fib2
	mov ax,1
	mov bx,1
	jmp main
fib1:
	mov ax,1
	mov result,ax
	jmp exit
fib2:
	mov ax,1
	mov result,ax
	jmp exit

main:	
	call fib
	jmp exit
fib proc near
	mov dx,ax
	mov ax,bx
	mov bx,dx
	add ax,bx
	dec cx
	cmp cx,2
	je getresult
	call fib

getresult:
	mov result,ax
	ret
fib endp
exit:
	mov dx,result
	add dx,30h
	mov ah,2h
	int 21h
	mov ah,4ch
	int 21h

codes ends
	end start
